// pages/myactivity/myactivity.js
import { Myactivity } from '../../model/myactivity.js'
const myactivity = new Myactivity();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        page:0,
        myactivity_list:[],
        count:0,
        loging:'没有更多了',
    },
    handlerGobackClick() {
        wx.navigateBack({
            delta: 1
        })
    },
    //我参与的活动
    my_activity(){
        
        // var obj={page:this.data.page}
        myactivity.user_join_items().then(res=>{
            console.log(res)
            var myactivity_list=this.data.myactivity_list
            for(var i=0;i<res.data.datums.length;i++){
                myactivity_list.push(res.data.datums[i])
            }
            this.setData({
                myactivity_list:myactivity_list,
                count:res.data.count,
                // myactivity_list:[]
            })
            console.log(this.data.myactivity_list)
        }).catch(error=>{
            console.log(error)
        })
    },
    // 去活动详情
  tomsg(e){
    console.log(e)
    console.log(e.currentTarget.dataset)
    if(e.currentTarget.dataset.item.classType == 1){
      wx.navigateTo({
        url: '/pages/activity_signup/activity_signup?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 2){
      wx.navigateTo({
        url: '/pages/activity_video/activity_video?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 3){
      wx.navigateTo({
        url: '/pages/vote/vote?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 4){
      wx.navigateTo({
        url: '/pages/dynamic/dynamic?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 5){
      wx.navigateTo({
        url: '/pages/inquiry/inquiry?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 6){
      wx.navigateTo({
        url: '/pages/stepnum/stepnum?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 7){
      wx.navigateTo({
        url: '/pages/location_signin/location_signin?id=' + e.currentTarget.dataset.item.classId,
      })
    }else if(e.currentTarget.dataset.item.classType == 8){
      wx.navigateTo({
        url: '/pages/share/share?id=' + e.currentTarget.dataset.item.classId,
      })
    }
  },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        // this.setData({
        //   array:[]
        // })
        this.my_activity()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {
        if(this.data.count>this.data.myactivity_list.length){
          this.setData({
              page:this.data.page+1,
              loging:'加载中...'
          })
          this.my_activity()
      }else{
          this.setData({
              loging:'没有更多了'
          })
      }
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})